<%@ WebHandler Language="C#" Class="CheckPorts" %>
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MySql.Data.MySqlClient;
using LdExpress;

public class CheckPorts : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        string stCode = "";
        if ((context.Request.QueryString.Get("name") != "") && (context.Request.QueryString.Get("name") != null))
        {
            stCode = context.Request.QueryString.Get("name");
        }
        string stVal = "";
        string sqlCommand = "";
        if (stCode.Length > 0)
        {
            sqlCommand = "Select * from tbl_ports where name='" + DBModule.RefineString(stCode) + "' limit 0,1";
            DataSet ds = DBModule.ExecuteQuery(sqlCommand, null, null);

            if (ds.Tables[0].Rows.Count > 0)
            {
                stVal = "False";
            }
            else { stVal = "OK"; }
        }
        context.Response.Cache.SetExpires(DateTime.Now.AddSeconds(600));
        context.Response.Cache.SetCacheability(HttpCacheability.Public);
        context.Response.Write(stVal);
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}